<?php

class CodeSpace_Jplugins_View_Helper_BgStretcher extends CodeSpace_Jplugins_View_Helper_JpluginsAbstract
{

    protected $_options = null;
        
    public function bgstretcher($options = array(), $params = null)
    {
//        $front = Zend_Controller_Front::getInstance();
//        $bootstrap = $front->getParam("bootstrap");
//        $defaultOptions = $bootstrap->getPluginResource('jplugins')->getOptions();
//        $defaultOptions = $defaultOptions['plugin']['bgstretcher'];
        
        $defaultOptions = new Zend_Config_Ini(APPLICATION_PATH . '/configs/jplugins.ini', 'bgstretcher');
        $defaultOptions = $defaultOptions->toArray();
        
        $options = array_merge($defaultOptions, $options);
        $this->_options = $options;
        $this->_options['name'] = 'bgstretcher';
         
        $images = glob($this->_options['option']['images'].'/*');
        $imageList = array();
        foreach ($images as $image){
            array_push($imageList, $this->view->baseUrl($image));
        }
        $images = "['" . implode("', '", $imageList) . "']";
    	$this->_options['option']['images'] = $images;
    	
        $this->setStyleSheets();
        $this->setJsFiles();
        $this->loadOptions();
        
        if($params != null){
            return $this->loadContent($params);
        }else {
            return $this->loadContent();
        }
    }

}
